package org.csmzxy.class2333.internal;
//外部类
public class Calculator {
    public void performCalculation(int num1,int num2,char operation){
        //局部内部类,用于表示计算器
        class OperationCalculator{
            public int add(){
                return num1+num2;
            }
            public int subtract(){
                return num1-num2;
            }
        }
        OperationCalculator calculator = new OperationCalculator();
        if(operation=='+'){
            System.out.println("计算结果:"+calculator.add());
        } else if (operation == '-') {
            System.out.println("计算结果:"+calculator.subtract());
        }else{
            System.out.println("发生错误！");
        }
    }
}
